<template>
    <!-- 添加对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal="false">
        <el-form :model="form" ref="form" size="small" :rules="rules">
            <el-row>
                <el-col :span="24">
                    <el-form-item prop="experimentAdvise">
                        <el-input type="textarea" :rows="6" :placeholder="$locale('myExperiment.proposal.Please provide experimental feedback')" v-model="form.experimentAdvise"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">{{ $locale('classList.add.determine') }}</el-button>
            <el-button @click="cancel">{{ $locale('classList.add.Cancel') }}</el-button>
        </div>
    </el-dialog>
</template>

  <script>
import { setExperimentAdvise } from "@/api/geWuExperiment";

export default {
    name: "proposal",
    data () {
        return {
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 表单参数
            form: {
                experimentAdvise: ''
            },
            // 表单校验
            rules: {
                experimentAdvise: [
                    { required: true, message: this.$locale('myExperiment.proposal.The experimental opinion cannot be empty'), trigger: "blur" }
                ]
            }
        };
    },
    created () {
    },
    methods: {
        // 表单重置
        reset () {
            this.form = {};
            this.resetForm("form");
        },
        show (row) {
            this.reset();
            this.open = true;
            this.form = row
            this.title = this.$locale('myExperiment.proposal.Please leave a message for experimental opinions!');
        },
        /** 提交按钮 */
        submitForm: function () {
            this.$refs["form"].validate(valid => {
                if (valid) {
                    setExperimentAdvise(this.form).then(response => {
                        this.$modal.msgSuccess(this.$locale('geWudevice.add.tip6'));
                        this.open = false;
                        this.$emit('getList');
                    });
                }
            });
        },
        // 取消按钮
        cancel () {
            this.open = false;
            this.reset();
        },
    }
};
</script>

<style lang="scss" scoped>
.el-rate {
    line-height: 2;
}
</style>
